// 2025/07/26
// Author: Forever
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n, m, a[800005], mx[800005], sum[800005];

void push_up(int p){
    mx[p] = max(mx[p << 1], mx[(p << 1) | 1]);
    sum[p] = sum[p << 1] + sum[(p << 1) | 1];
}

void build(int p, int l, int r){
    if (l == r){
        mx[p] = sum[p] = a[l];
        return;
    }
    int m = (l + r) >> 1;
    build(p << 1, l, m);
    build((p << 1) | 1, m + 1, r);
    push_up(p);
}

void sq(int l, int r, int s, int t, int p){
    if (s == t){
        sum[p] = sqrt(sum[p]), mx[p] = sqrt(mx[p]);
        return;
    }
    int m = s + ((t - s) >> 1);
    if (l <= m && mx[p << 1] > 1)
        sq(l, r, s, m, p << 1);
    if (r > m && mx[(p << 1) | 1] > 1)
        sq(l, r, m + 1, t, (p << 1) | 1);    
    push_up(p);
}

int query(int l, int r, int s, int t, int p){
    if (l <= s && t <= r){
        return sum[p];
    }
    int m = s + ((t - s) >> 1);
    int res = 0;
    if (l <= m)
        res += query(l, r, s, m, p << 1);
    if (r > m)
        res += query(l, r, m + 1, t, (p << 1) | 1);    
    return res;
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    build(1, 1, n);
    cin >> m;
    while (m--){
        int op, l, r;
        cin >> op >> l >> r;
        if (l > r)
            swap(l, r);
        if (op == 1)
            cout << query(l, r, 1, n, 1) << endl;
        else
            sq(l, r, 1, n, 1);
    }
    return 0;
}